const Router = require("koa-router");

const router = new Router({ prefix: "/topics" });

const { auth } = require("../middleware/auth.middleware");

const {
  upload,
  create,
  getAll,
  postComment,
  getTopicComent,
  getAllTopicsAndComments,
  likePost,
  dislikePost,
  deleteMyTopic,
} = require("../controller/topic.controller");

const { topicValidator } = require("../middleware/topic.middleware");

//!帖子图片上传接口
router.post("/upload", auth, upload);

//!帖子详情发布接口
router.post("/", auth, create);

//!返回所有的帖子
router.get("/get_all_topics", getAll);

router.post("/post_comment", auth, postComment);

router.get("/get_topic_comments/:topic_id", getTopicComent);

router.get("/get_all_topics_including_comments", getAllTopicsAndComments);

//!用户点赞某帖子
router.post("/like_post", likePost);

router.post("/dislike_post", dislikePost);

router.post("/delete_my_topic", deleteMyTopic);

module.exports = router;
